#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string s;
    while (getline(cin, s)) //读取一行字符串
    {
        vector<char> v;
        for (unsigned i = 0; i < s.length(); i++)
        {
            v.push_back(s[i]);
        }
        sort(v.begin(), v.end()); //从小到大排序
                                  //最大的应该是反过来的，就用倒转迭代器reverse_iterator
        for (vector<char>::reverse_iterator it = v.rbegin(); it != v.rend(); it++)
        {
            cout << *it;
        }
        cout << endl;
        //最小的要去掉前导0，用continue跳过0
        for (vector<char>::iterator it = v.begin(); it != v.end(); it++)
        {
            if (*it == '0')
                continue;
            cout << *it;
        }
        cout << endl;
    }
    return 0;
}
